import request from '/src/axios.js'
import {baseUrl} from "@/config/env.js";

const erpUrl = baseUrl + '/api-erp-oa/'

/**
 * 公告添加
 * @param {*} data
 */
export function noticeListAPI(data) {
    return request({
        url: erpUrl + 'oaAnnouncement/queryList',
        method: 'post',
        data: data
    })
}

/**
 * 公告添加或编辑
 * @param {*} data
 */
export function noticeAddOrUpateAPI(data) {
    var url = data.announcementId ? 'setAnnouncement' : 'addAnnouncement'
    return request({
        url: erpUrl + 'oaAnnouncement/' + url,
        method: 'post',
        data: data,
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}

/**
 * 公告删除
 * @param {*} data
 */
export function noticeDeleteAPI(id) {
    return request({
        url: erpUrl + `oaAnnouncement/delete/${id}`,
        method: 'post'
    })
}

/**
 * 公告详情
 * @param {*} data
 */
export function noticeQueryByIdAPI(id) {
    return request({
        url: erpUrl + `oaAnnouncement/queryById/${id}`,
        method: 'post'
    })
}


/**
 * 公告设为已读
 * @param {*} data
 */
export function noticeIsReadAPI(data) {
    return request({
        url: erpUrl + 'oaAnnouncement/readAnnouncement',
        method: 'post',
        data: data
    })
}
